package com.loong.data.controller.forehead;

import com.loong.common.mvc.BaseForeheadController;
import com.loong.common.param.BaseIdParam;
import com.loong.common.rest.Result;
import com.loong.common.validator.group.CommonValidate;
import com.loong.data.common.forehead.param.*;
import com.loong.data.handler.ShopHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description: 处理前台有关店铺请求的controller
 * @Author: 刘群
 * @Date: 2020/11/11 11:59
 */
@Slf4j
@RestController
@RequestMapping("forehead/data/shop")
public class ShopForeheadController extends BaseForeheadController {

    @Resource
    private ShopHandler shopHandler;

    /**
     * 根据店铺id搜索店铺
     * @param param 店铺id
     * @return 响应的结果
     */
    @PostMapping("findById")
    public Result findShopModelById(@RequestBody @Validated({CommonValidate.class})BaseIdParam param){
        return handlerExecutor.execute(() -> shopHandler.foreheadFindShopModelById(param));
    }

    /**
     * 根据距离和店铺查询参数查询店铺
     * @param param 距离、店铺查询参数、分页封装的参数
     * @return 响应的结果
     */
    @PostMapping("findShopListByDistance")
    public Result findShopByDistance(@RequestBody @Validated(value = CommonValidate.class) DistanceAndShopQueryForeheadParam param){
        return handlerExecutor.execute(() -> shopHandler.findShopForeheadByDistance(param));
    }

    /**
     * 根据参数搜索店铺或者商品
     * @param param 距离、店铺查询参数、分页封装的参数
     * @return 响应的结果
     */
    @PostMapping("findShop")
    public Result findShopOrGoodsByParam(@RequestBody @Validated(value = CommonValidate.class) DistanceAndShopQueryForeheadParam param){
        return handlerExecutor.execute(() -> shopHandler.foreheadFindShopOrGoodsByParam(param));
    }


}
